﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.Model;
using Reservoir.BLL;
using Reservoir.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Reservoir.WebSite
{
    public partial class Reporting : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            //第一次加载页面
            if (!IsPostBack)
            {
                // 读取用户资料
                TBUser user = IdentityManager.ReadUser1();
                lblUserId.Text = user.Id;
                lblName.Text = user.Name;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            TBRecord record = new TBRecord();
            record.UserId = lblUserId.Text;
            record.District = hidAddress.Value;
            record.Name = this.txtName.Text;
            record.Area = Convert.ToDouble(this.txtArea.Text);
            record.Storage = Convert.ToDouble(this.txtStorage.Text);
            record.Functional = Functional.Value;
            record.Maximum = Convert.ToDouble(this.txtMaximum.Text);
            record.Curent = Convert.ToDouble(this.txtCurent.Text);
            record.Remarks = this.txtRemarks.Text;
            RecordBLL userManager = new RecordBLL();
            OperResult editResult = userManager.AddRecord(record);

            if (editResult == null)
            {
                this.Alert("editerror", editResult.Message);
            }
            else
            {
                // 跳转到个人页
                Response.Redirect("Record.aspx");
            }
        }
    }
}